package demo1;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

class Send implements Runnable{

	 private DatagramSocket ds;
	

	public Send(DatagramSocket ds) {
		this.ds = ds;
	}


	@Override
	public void run() {
		try {
		BufferedReader buff=new BufferedReader(
				new InputStreamReader(System.in));
		String line=null;
		
			while((line=buff.readLine())!=null){
				if("bye".equals(line)) break;
				else{
				byte[] buf=line.getBytes();
				DatagramPacket dp=new DatagramPacket(buf, buf.length,
						InetAddress.getByName("192.168.1.255"), 8000);
				ds.send(dp);
			}
				}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
 }

